package com.trdcore.zyzkt.controller;


import com.trdcore.zyzkt.model.vod.Video;
import com.trdcore.zyzkt.resp.ResultData;
import com.trdcore.zyzkt.service.VideoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author Luffy
 * @since 2024-03-18
 */
@RestController
@RequestMapping("/admin/vod/video")

@Tag(name = "小节")
public class VideoController {

    @Autowired
    private VideoService videoService;

    @Operation(summary = "获取",description = "获取")
    @GetMapping("get/{id}")
    public ResultData get(@PathVariable("id") Long id) {
        Video video = videoService.getById(id);
        return ResultData.success(video);
    }
    @Operation(summary = "新增",description = "新增")
    @PostMapping("save")
    public ResultData save(@RequestBody Video video) {
        return ResultData.success(videoService.save(video));
    }
    @Operation(summary = "修改",description = "修改")
    @PutMapping("update")
    public ResultData updateById(@RequestBody Video video) {
        return ResultData.success( videoService.updateById(video));
    }
    @Operation(summary = "删除",description = "删除")
    @DeleteMapping("remove/{id}")
    public ResultData remove(@PathVariable("id") Long id) throws Exception {
        videoService.removeVideoById(id);
        return ResultData.success(null);
    }

}

